﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SelectGoodsWindow.aspx.cs"
    Inherits="PSS.WebSite.CommForm.SelectGoodsWindow" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>商品选择</title>
    <script src="../lib/boot.js" type="text/javascript"></script>
</head>
<body>
    <div class="mini-toolbar" style="padding: 2px; border-top: 0; border-left: 0; border-right: 0;">
        <table>
            <tr>
                <td align="right">
                    商品类别：
                </td>
                <td style="width: 150px;" align="left">
                    <input id="GCategoryId" class="mini-combobox" style="width: 150px;" valuefield="GCategoryId"
                        textfield="GCategoryName" />
                </td>
                <td align="right">
                    商品编号：
                </td>
                <td style="width: 150px;" align="left">
                    <input id="GoodsCode" class="mini-textbox" emptytext="请输入商品编号" style="width: 150px;"
                        onenter="onKeyEnter" />
                </td>
                <td style="width: 100px;">
                    <a class="mini-button" iconcls="icon-search" onclick="search()">查 询</a>
                </td>
            </tr>
            <tr>
                <td align="right">
                    商品名称：
                </td>
                <td style="width: 150px;" align="left">
                    <input id="GoodsName" class="mini-textbox" emptytext="请输入商品名称" style="width: 150px;"
                        onenter="onKeyEnter" />
                </td>
                <td align="right">
                    规格型号：
                </td>
                <td style="width: 150px;" align="left">
                    <input id="Specific" class="mini-textbox" emptytext="请输入规格型号" style="width: 150px;"
                        onenter="onKeyEnter" />
                </td>
                <td style="width: 100px;">
                    <a class="mini-button" iconcls="icon-reset" onclick="reset()">重 置</a>
                </td>
            </tr>
        </table>
    </div>
    <div class="mini-toolbar" style="padding: 2px; border-bottom: 0; border-top: 0; border-left: 0;
        border-right: 0;">
        <table style="width: 100%;">
            <tr>
                <td style="width: 100%;">
                    <a class="mini-button" id="add" iconcls="icon-add" onclick="view();" plain="true">及时库存</a>
                </td>
            </tr>
        </table>
    </div>
    <!--撑满页面-->
    <div class="mini-fit">
        <div id="grid1" class="mini-datagrid" style="width: 100%; height: 100%;" idfield="GoodsId"
            sizelist="[10,20,50,100]" pagesize="20" onrowdblclick="ondoubleclick()" borderstyle="border-left:0;border-right:0;"
            multiselect="true">
            <div property="columns">
                <div type="checkcolumn">
                </div>
                <div field="GCategoryName" width="90" headeralign="center" allowsort="true">
                    商品类别
                </div>
                <div field="GoodsCode" width="120" headeralign="center" allowsort="true">
                    商品编号
                </div>
                <div field="GoodsName" width="120" headeralign="center" allowsort="true">
                    商品名称
                </div>
                <div field="Specific" width="120" headeralign="center" allowsort="true">
                    规格型号
                </div>
                <div field="UnitName" width="60" headeralign="center" allowsort="true">
                    单位
                </div>
            </div>
        </div>
    </div>
    <div class="mini-toolbar" style="text-align: center; padding-top: 8px; padding-bottom: 8px;"
        borderstyle="border:0;">
        <a class="mini-button" iconcls="icon-ok" style="width: 60px;" onclick="onOk()">确定</a>
        <span style="display: inline-block; width: 25px;"></span><a class="mini-button" iconcls="icon-cancel"
            style="width: 60px;" onclick="onCancel()">取消</a>
    </div>
    <script type="text/javascript">
        mini.parse();
        var GCategoryId = mini.get("GCategoryId");
        GCategoryId.setUrl("../../Service/SetManageHandler.ashx?action=GetGoodsCategoryListByCombobox");
        var grid = mini.get("grid1");
        grid.setUrl("../../Service/SetManageHandler.ashx?action=GetGoodsList");
        grid.load();
        function search(e) {
            var GCategoryId = mini.get("GCategoryId").getValue();
            var GoodsCode = mini.get("GoodsCode").getValue();
            var GoodsName = mini.get("GoodsName").getValue();
            var Specific = mini.get("Specific").getValue();
            grid.load({ GCategoryId: GCategoryId, GoodsCode: GoodsCode, GoodsName: GoodsName, Specific: Specific });
        }
        function onKeyEnter(e) {
            search();
        }
        function reset(e) {
            mini.get("GCategoryId").setValue("");
            mini.get("GoodsCode").setValue("");
            mini.get("GoodsName").setValue("");
            mini.get("Specific").setValue("");
        }
        function GetData() {
            var rows = grid.getSelecteds();
            var data = [];
            for (var i = 0, l = rows.length; i < l; i++) {
                var row = {};
                row.GoodsId = rows[i].GoodsId;
                row.GoodsCode = rows[i].GoodsCode;
                row.GoodsName = rows[i].GoodsName;
                row.Specific = rows[i].Specific;
                row.UnitName = rows[i].UnitName;
                row.Qty = 0;
                row.PurchasePrice = rows[i].PurchasePrice;
                row.SalePrice = rows[i].SalePrice;
                row.DiscountRate = 0;
                row.Deduction = 0;
                row.PurchaseAmount = 0;
                row.StorageId = rows[i].StorageId;
                row.StorageName = rows[i].StorageName;
                data.push(row);
            }
            return data;
        }
        function ondoubleclick() {
            onOk();
        }
        function onOk() {
            var rows = grid.getSelecteds();
            if (rows) {
                CloseWindow("ok");
            }
            else {
                mini.alert("请选中一条您需要添加的记录!");
            }
        }
        function view() {
            var row = grid.getSelected();
            if (row) {
                mini.open({
                    url: "CommForm/SelectInventoryQtyWindow.aspx",
                    title: row.GoodsCode + " " + row.GoodsName + "及时库存", width: 300, height: 200,
                    onload: function () {
                        var iframe = this.getIFrameEl();
                        var data = { action: "view", GoodsId: row.GoodsId };
                        iframe.contentWindow.SetData(data);
                    },
                    ondestroy: function (action) {
                        //grid.reload();
                    }
                });
            } else {
                mini.alert("请选中一条记录!");
            }
        }
        function CloseWindow(action) {
            if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();
        }
        function onCancel() {
            CloseWindow("close");
        }
    </script>
</body>
</html>
